Vue Js Get Hash(#) from Url: VueJS uses the hash from the URL to determine which page needs to be rendered on a user’s device, as well as any specific parameters associated with that page. The location.hash property is a string that allows you to access the URL fragment or “hash” of a page, including the hash sign (#). The location hash property can be used to get the value after the “#” character from a URL With the help of the location.hash property in Vue.js, you can get the hash part of a given URL. With our online editor, you can easily write, edit, and run your code on the same platform.
How to get the hash value from a URL using Vue Js ?
To get the hash value from a URL using Vue.js, you can use the location object and its hash property.
<div id="app">
<a id="link" href="https://fontawesomeicons.com/bootstrap-table/#table-pagination-text-added-dynamically">Bootstrap table</a><br/>
<button @click="myFunction">click me</button>
<p>{{result}}</p>
</div>
<script type="module">
import { createApp } from "vue";
createApp({
data() {
return {
result: "",
url: "",
};
},
methods: {
myFunction() {
this.url = link;
this.result = this.url.hash;
},
},
}).mount("#app");
</script>